/**
 * @Author: lifuzhao
 * @Date: 2019-05-15
 * @Project: eabax
 */
import Vue from 'vue'
import $ from 'cheerio'
const install =  Vue => {
  Vue.prototype.$fn = {
    getBase64(file){
      return new Promise(resolve => {
        let reader = new FileReader()
        reader.onload = () => {
          resolve(reader.result)
        }
        reader.readAsDataURL(file)
      })
    },
    // 去除base64头部内容
    extractBase64(base64){
      return base64.replace(/data:image.*?,/, '')
    },
    openQQ(){
      window.open('http://wpa.qq.com/msgrd?v=3&uin=949609005&site=qq&menu=yes', '_blank')
    },
    getTextContent(text){
      let content = JSON.parse(text)
      try{
        content = $(content).text()
      }catch (e) {
        throw e
      }
      return content
    }
  }
}
Vue.use(install)
